﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class DiceTextureSelect : MonoBehaviour {

	public UIPopupList Popup;
	public UIPopupList Popup_attacker;
	public UIPopupList Popup_defender;
	bool bClose;

	public static Dictionary<string, int> diceTexNum = new Dictionary<string, int>()
	{
		{"dice_01",1},
		{"dice_02",2},
		{"dice_03",3},
		{"dice_04",4},
		{"dice_05",5},
		{"dice_06",6},
		{"dice_07",7},
		{"dice_08",8},
		{"dice_09",9},
	};	

	void Awake()
	{
		if(Popup!=null)
			Popup.value = "dice_0" + IngameSetting.Instance.nDiceNormal.ToString();
		else if(Popup_attacker!=null)
			Popup_attacker.value = "dice_0" + IngameSetting.Instance.nDiceAttacker.ToString();
		else if(Popup_defender!=null)
			Popup_defender.value = "dice_0" + IngameSetting.Instance.nDiceDefender.ToString();
		else
			bClose=true;
	}

	public void OnPopupList_diceTexture()
	{
		Debug.Log("OnPopupList_diceTexture " + Popup.value);
		IngameSetting.Instance.nDiceNormal = diceTexNum[Popup.value];
		BoardManager.Instance.curDiceShapeType = DiceShapeType.None;
	}
	
	public void OnPopupList_diceTexture_attacker()
	{
		Debug.Log("OnPopupList_diceTexture_attacker " + Popup_attacker.value);
		IngameSetting.Instance.nDiceAttacker = diceTexNum[Popup_attacker.value];
		BoardManager.Instance.curDiceShapeType = DiceShapeType.None;
	}
	
	public void OnPopupList_diceTexture_defender()
	{
		Debug.Log("OnPopupList_diceTexture_defender " + Popup_defender.value);
		IngameSetting.Instance.nDiceDefender = diceTexNum[Popup_defender.value];
		BoardManager.Instance.curDiceShapeType = DiceShapeType.None;
	}
	void OnClick()
	{
		if(bClose)
			UIManager.Instance.testDiceColorPanel.SetActive(false);
	}
}
